<!DOCTYPE html>
<html class="pixel-ratio-1 watch-active-state">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="theme-color" content="">
    <title>注册</title>
    <link rel="stylesheet" href="/resources/wap/css/framework7_002.css">
    <link rel="stylesheet" href="/resources/wap/css/style.css">

    <script src="/resources/common/js/jquery-1.11.3.min.js"></script>
    <script type="text/javascript" src="/resources/common/js/md5.js"></script>
    <script type="text/javascript" src="/resources/js/self.js"></script>
    <script type="text/javascript" src="/resources/js/Util.js"></script>
    <style type="text/css">
        .dlbox input{
            border: none !important;
            border-bottom: 1px solid !important;
            border-radius: 0px;
            text-align: left;
        }
        .getVerifyCode{

        }
    </style>

</head>
<body>
<div class="turnon"></div>
<div class="navbar">
    <div class="navbar-inner">
        <div class="center"><a href="login.html">注册</a></div>
    </div>
</div>

<div class="dlbox">
    <input name="account" class="dlyhm" type="text" placeholder="账号(手机号)" foundfield="" compareway="2">
</div>

<div class="dlbox" >
    <input name="verifyCode"  style="width: 70%" class="dlyhm" type="text" placeholder="验证码" foundfield=""  compareway="2">
    <a class="getVerifyCode" href="javascript:void(0)"  onclick="sendVerify();">获取验证码</a>
</div>

<div class="dlbox"><input name="name" class="dlyhm" type="text" placeholder="姓名" foundfield="" compareway="2"></div>
<div class="dlbox"><input name="password" class="dlyhm" type="password" placeholder="密码" foundfield="" compareway="2"></div>
<div class="dlbox"><input name="cfPassword" class="dlyhm" type="password" placeholder="重复密码" foundfield="" compareway="2"></div>

<!--<div class="zcbox"><input name="" class="zcyhm" type="text" placeholder="验证码" foundfield="" compareway="2">

    <div class="fsyzm">发送验证码</div>
</div>-->
<div class="zcbut register"><a href="javascript:void(0)">注册</a></div>
<div class="yyhm">已有账号，<a href="login.html">点击登录</a></div>
</body>
<script type="text/javascript">
    $(function () {
        $(".register").click(function () {
            var account = $("input[name='account']").val();
            var password = $("input[name='password']").val();
            var name = $("input[name='name']").val();
            var cfPassword = $("input[name='cfPassword']").val();
            var verifyCode =  $("input[name='verifyCode']").val();
            if(isNullOrUndefined(account)) {
                alert("请输入账号");
                return;
            }
            if(!checkMobile(account)) {
                alert("账号应该为手机号格式");
                return;
            }
            if(isNullOrUndefined(name)) {
                alert("请输入姓名");
                return;
            }
            if(isNullOrUndefined(password)) {
                alert("密码不能为空");
                return;
            }
            if(isNullOrUndefined(verifyCode)) {
                alert("验证码不能为空");
                return;
            }
            if(password.length < 6) {
                alert("密码至少为6位");
                return;
            }
            if(password != cfPassword) {
                alert("两次密码不一致，清重新输入");
                return;
            }
            var params = {};
            params['account'] = account;
            params['password'] = hex_md5(password);
            params['name'] = name;
            params['verifyCode']=verifyCode;
            $.ajax({
                url:'/wap/supplier/registerOn.do',
                type:'post',
                data: params,
                success:function(data){
                    if(data.success){
                        alert("注册成功");
                        window.location.href = "/html/wap/supplier/user_center.html?random="+new Date().getTime();
                    }else{
                        alert(data.msg);
                    }
                },
                error:function () {
                    alert("系统错误！");
                }
            });
        });



    })
    function sendVerify() {
        var telephone = $("input[name='account']").val();
        var param = {"telephone":telephone}
        $.ajax({
            url:'/sms/sendVerify.json',
            type:'post',
            data: param,
            success:function(data){
                if(data.success){
                    alert("已发送！");
                }else{
                    alert(data.msg);
                }
            },
            error:function () {
                alert("系统错误！");
            }
        });
    }
</script>
</html>